<html>
  <head>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body class="tundra">
  <script>
      var dojoConfig = {
          async:true,
          packages: [
              { name: "rforms", location: "../../../src/rforms" },
              { name: "rdfjson", location: "../../../src/rdfjson" }]
      };
  </script>
  <script src="../lib/dojo/dojo/dojo.js.uncompressed.js"></script>


	<style>
		@import "../lib/dojo/dijit/themes/tundra/tundra.css"; /* required when dijit */	
		@import "../src/rforms/view/resources/rforms.css";
	</style>

	<script type="text/javascript">


        require(['rdfjson/converters',     //Contains the rdf/json to rdf/xml converter
            'dojo/json',                   //To serialize/deserialize the json
            'dijit/registry',              //To access the dijits
            'dojo/parser',                 //To parse the inline template
            'dijit/form/SimpleTextarea',   //Used in the template
            'dojo/text!./testgraph.rdf',   //RDF/XML testdata.
            'dojo/domReady!'               //Wait until the dom is ready.
        ], function(converters, json, registry, parser, SimpleTextarea, testdata) {
            parser.parse(); //Init the dijits in the dom.
            registry.byId("source").set("value", testdata); //Show the source rdfxml

            //------Here is where the conversion from rdfxml to rdfjson happens.--------
            var graph = converters.rdfxml2graph(testdata)
            var jsonrdf = graph.exportRDFJSON();
            //---------------------------------------------------------------------------

            registry.byId("destination").set("value", json.stringify(jsonrdf, true, "  ")); //Show the resulting rdf/json.
		});
	</script>
	<div style="width:50%;height:100%;float:left;">
		<h1>RDF/XML loaded from testgraph.rdf</h1>
		<div dojoType="dijit.form.SimpleTextarea" style="width: 99%;height:500px;" id="source"></div>
	</div>
	<div style="width:50%;height:100%;float:left;">
		<h1>Converted to RDF/JSON</h1>
		<div dojoType="dijit.form.SimpleTextarea" style="width:99%;height:500px;" id="destination"></div>
	</div>
  </body>
</html>